#!/bin/sh
# Start/stop/restart the hal daemon:

PIDFILE=/var/run/hald.pid

hal_start()
{
  if [ -x /usr/sbin/hald ]; then
    if [ $(uname -r | cut -d. -f1) -ge 2 ]; then
      if [ $(uname -r | cut -d. -f2) -ge 6 ]; then
        echo "Starting HAL daemon:  /usr/sbin/hald"
        /usr/sbin/hald --daemon=yes
      else
        echo "You must be running a 2.6 kernel for HAL to work. "
        exit 1
      fi
    else
      echo "You must be running a 2.6 kernel for HAL to work. "
      exit 1
    fi
  fi
}

hal_stop()
{
  kill $(cat $PIDFILE) || killall hald
  rm -f $PIDFILE
}

# See how we were called.
case "$1" in
    start)
        hal_start
        ;;
    stop)
        hal_stop
        ;;
    restart)
        hal_stop
	sleep 1
        hal_start
        ;;
    *)
        echo $"Usage: $0 {start|stop|restart}"
        ;;
esac

